<template>
  <div>
    home

    <el-button type="primary" :loading="loading" @click="loadUserNum"
      >加载用户数量{{ userNum }}</el-button
    >

    <el-button type="primary" :loading="loadingPro" @click="loadProNum"
      >加载商品数数量{{ proNum }}</el-button
    >
  </div>
</template>
<script lang="ts">
import { getAllUserNum, getAllProductNum } from '@/api/home'
import axios from 'axios'
export default {
  data() {
    return {
      loading: false,
      loadingPro: false,
      userNum: 0,
      proNum: 0,
    }
  },
  mounted() {
    axios
      .get(
        'https://weibo.com/ajax/side/searchBand?type=mine&last_tab=mine&last_tab_time=1730972958',
      )
      .then(r => {
        console.log(r)
      })

    // const ws = new WebSocket('//ws服务器地址')
    // // 给服务器发消息
    // // ws.send('要发送的内容')
    // //监听服务器给我回的消息
    // ws.onmessage = function (data) {
    //   console.log(data)
    // }
  },
  methods: {
    loadUserNum() {
      this.loading = true
      getAllUserNum().then(r => {
        this.loading = false
        console.log(r.data)

        this.userNum = r.data.data
      })
    },
    loadProNum() {
      this.loadingPro = true
      // 按下alt按键--点击函数-快速跳转函数定义的地方
      getAllProductNum().then(r => {
        console.log(r.data)
        this.proNum = r.data.data
        // r.data.data

        this.loadingPro = false
      })
    },
  },
  created() {
    this.loadUserNum()
    this.loadProNum()
  },
}
</script>
<style lang=""></style>
